#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QPlainTextEdit>
#include <QComboBox>
#include <QPushButton>
#include <QLineEdit>
#include <QScrollArea>
#include <QLabel>
#include <QCheckBox>
#include <QScrollArea>

#include <QGridLayout>
#include <QVBoxLayout>

#include <QMessageBox>
#include <QThread>
#include <QDebug>
#include <QTextCodec>
#include <QTimer>

#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>

#include "tcv_dmhandle.h"
#include "opencv.hpp"

namespace Ui {
class Widget;
}

class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = 0);
    ~Widget();

private:
    Ui::Widget *ui;

    //Chinese support 中文支持
    QTextCodec *codec;

    //************ UI **************
    void UI_Init();
    //layout_serial
    //SERIAL
    QPushButton *OpenButton;

    QPlainTextEdit *RecvText;
    QLineEdit *SendText;
    QComboBox *ComboBox;

    QTimer *SerialDelayTimer;

    //layout_location
    //坐标参数显示
    std::vector <QLabel*> ArmVal_label;
    std::vector <QLabel*> ArmValLab_label;

    //Scroll外体控件
    QScrollArea *scrollarea;
    QWidget *ScrollWidget;
    QGridLayout *ScrollLayout;

    //Scroll内部控件
    std::vector <QPushButton*> Scroll_button;   //按键
    std::vector <QLineEdit*> Scroll_lineedit;   //指令框
    std::vector <QLineEdit*> Scroll_delay_lineedit; //延时框
    std::vector <QCheckBox*> Scroll_checkbox;   //使能连续发送选项框

    std::vector <QLabel*> comment;

    //3.4-Scroll下方控件
    //layout_buttongroup
    //text and send label/checkbox
    QCheckBox *ContinSend_CheckBox;
    QCheckBox *ContinSend_Precise_CheckBox;

    QLabel *ChatStatu_Label;

    //text and send button
    QPushButton *AddScrComButton;

    QPushButton *ContinSendButton;
    QPushButton *ContinSend_Precise_Button;

    QPushButton *StopContinSendButton;

    //3.4-cv搜索控件
    //open carmera
    QPushButton *Open_Close_Carmera;

    //search connect
    QPushButton *SearchCupButton;
    QLabel *SearchCupLabel;

    //AUTO run
    QLabel *AutoRunLabel;
    QCheckBox *AutoRunCheckBox;
    QPushButton *AutoRunButton;

    //search apart
    QPushButton *SearchCup_Dect_Button;
    QPushButton *SearchCup_Dis_Button;

    //3.5-cv展示区域
    //layout_cvshow
    //3.5.1-camera control
    QComboBox *ComboBox_CameraId1;
    QPushButton *Button_CameraIdOpen1;
    QComboBox *ComboBox_CameraId2;
    QPushButton *Button_CameraIdOpen2;
    QPushButton *Button_CameraIdSearch;
    //3.5.2-dect server control
    QPushButton *Button_StartQueuePush;
    QLabel *Lable_ShowQueueSize;
    QPushButton *Button_DectForOnce;
    //3.5.3-dect show
    QLabel *Lable_showDectPoint;

    //3.6-picture展示区域
    QLabel *Lable_showPicture;
    QLabel *Lable_showDectPicture;

    //LAYOUT
    QVBoxLayout *layout_main;


    //************ value **************
    TCV_DMHandle m_TcvDmHandle;


    //************ CV **************
    //video play
    QTimer *Timer_VideoPlay;
    //show size
    unsigned int m_showImageWidth = 640*0.4;
    unsigned int m_showImageHeight = 480*0.4;

private slots:
    //************ UI **************
    void SL_BTNCameraIdSearch();
    void SL_BTNCameraIdOpen1();

    //************ CV **************
    //video play
    void SL_TimerVideoPlay();
    //dect server control
    void SL_BtnStartStopDectServer(bool i_judge);
    //start dect for once
    void SL_DectForOnce();
    //dect finish recall
    void SL_DectFinishWidgetRecall(cv::Point point);
};

#endif // WIDGET_H
